package br.ita.comp.ces22.quiz.core.dao;

import br.ita.comp.ces22.quiz.core.PropertiesLoader;
import br.ita.comp.ces22.quiz.core.dao.jdbc.JDBCDAOFactory;
import br.ita.comp.ces22.quiz.core.dao.jpa.JPADAOFactory;
import br.ita.comp.ces22.quiz.core.exception.InvalidAccessTypeException;
import br.ita.comp.ces22.quiz.domain.Question;

public abstract class DAOFactory {
	
	public static DAOFactory getDAOFactory() throws InvalidAccessTypeException {
		
		String config = PropertiesLoader.getField("access");
		
		if(config.equals("JDBC"))
			return new JDBCDAOFactory();
		else if(config.equals("JPA"))
			return new JPADAOFactory();
		
		throw new InvalidAccessTypeException(config);
	}
	
	public abstract UserDAO getUserDAO();

	public abstract DAO<Question> getQuestionsDAO();
	
	public abstract QuizDAO getQuizDAO();
	
}
